cmake_minimum_required(VERSION 3.8)
project(arm_control)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(message_filters REQUIRED)
find_package(serial REQUIRED)
find_package(Eigen3 REQUIRED)

add_executable(arm_joint src/arm_joint.cpp)
add_executable(arm_adc   src/arm_adc.cpp)
add_executable(arm_encoder  src/arm_encoder.cpp)
add_executable(test_1         src/test_1.cpp)
add_executable(arm_kinematic src/arm_kinematic.cpp)
add_executable(arm_constyle src/arm_constyle.cpp)
add_executable(arm_constyle2 src/arm_constyle2.cpp)
add_executable(arm_constyle3 src/arm_constyle3.cpp)

target_include_directories(arm_joint PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/arm_control>
  $<INSTALL_INTERFACE:include>)
target_include_directories(arm_encoder PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/arm_control>
  $<INSTALL_INTERFACE:include>)
include_directories(${EIGEN3_INCLUDE_DIR})
target_compile_features(arm_joint PUBLIC c_std_99 cxx_std_17)  # Require C99 and C++17

ament_target_dependencies(
  arm_joint
  "rclcpp"
  "std_msgs"
  "message_filters"
  "serial"
)

ament_target_dependencies(
  arm_adc
  "rclcpp"
  "std_msgs"
  "message_filters"
  "serial"
)

ament_target_dependencies(
  arm_encoder
  "rclcpp"
  "std_msgs"
  "message_filters"
  "serial"
)


ament_target_dependencies(
  test_1
  "rclcpp"
  "std_msgs"
  "message_filters"
  "serial"
)

ament_target_dependencies(
  arm_kinematic
  "rclcpp"
  "std_msgs"
)

ament_target_dependencies(
  arm_constyle
  "rclcpp"
  "std_msgs"
)

ament_target_dependencies(
  arm_constyle2
  "rclcpp"
  "std_msgs"
)

ament_target_dependencies(
  arm_constyle3
  "rclcpp"
  "std_msgs"
  "geometry_msgs"
)

target_link_libraries(arm_joint ${CONTROLCAN} controlcan)
target_link_libraries(arm_encoder ${CONTROLCAN} controlcan)

install(TARGETS 
  arm_joint
  arm_adc
  arm_encoder
  test_1
  arm_kinematic
  arm_constyle
  arm_constyle2
  arm_constyle3
  DESTINATION lib/${PROJECT_NAME})

if(BUILD_test_1ING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files
  set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_1_dependencies()
endif()

ament_package()
